//
//  AppDelegate.swift
//  WeiBoPro
//
//  Created by nadyboy on 2018/4/26.
//  Copyright © 2018年 hjh. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        self.window = UIWindow.init(frame: UIScreen.main.bounds)
        self.window?.backgroundColor = UIColor.white
        self.window?.rootViewController = HJHTabBarController()
        self.window?.makeKeyAndVisible()
        
        //模拟从网络加载数据
        loadData()
        return true
    }
}
extension AppDelegate
{
    func loadData() {
        DispatchQueue.global().async {

            let path = Bundle.main.url(forResource: "main.json", withExtension: nil)
            let data = NSData(contentsOf: path!)
            let dir = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
            let filePath = (dir as NSString).appendingPathComponent("main.json")
           data?.write(toFile: filePath, atomically: true)
        }
    }
}
